#include "MiniGame.h"

// Initialize the instance to null
MiniGame* MiniGame::m_MiniGameInstance = 0;

MiniGame::MiniGame(void)
{
}

MiniGame::~MiniGame(void)
{
}

MiniGame* MiniGame::GetInstance(void)
{
	// Create the singleton if it doesn't exist
	if(!m_MiniGameInstance)
		m_MiniGameInstance = new MiniGame;

	// Return the singleton
	return m_MiniGameInstance;
}

void MiniGame::DeleteMiniGameInstance(void)
{
	// If instance exist, delete it!
	if(m_MiniGameInstance)
	{
		delete m_MiniGameInstance;
		m_MiniGameInstance = NULL;
	}
}

void MiniGame::InitMiniGame(IDirect3DDevice9* m_pD3DDevice)
{
	// Seed the randomizer
	srand((short)timeGetTime());

	// INSTANCES
	m_pSpriteManager = SpriteManager::GetInstance();
	m_pModelManager = ModelManager::GetInstance();
	m_pSound = Sound::GetSoundInstance();
	m_pText = Text::GetInstance();

	// Initialize the timer
	lStartTime = (LONG)timeGetTime();

	// Initialize the win/lose conditions
	bGameWon = false;
	bGameOver = false;

	bSuccess = false;
	bOutOfTime = false;
	bYouFailed = false;
	// Controls the timer so it will countdown when it is suppose too.
	bTimer = true;
}

void MiniGame::LoadMiniGame(short sGameNum, short sTerminalIn)
{
	// Set the game ID to the mini game we want to use
	sGameID = sGameNum - 1;
	sTerminal = sTerminalIn;
	// Set the losses and game state
	sLosses = 0;
	sCounter = 0;
	// Set the timer for clicking the mouse
	sClickTimer = 0;
	// Set the game variables
	bGameWon = false;
	bGameOver = false;
	bSuccess = false;
	bOutOfTime = false;
	bYouFailed = false;
	sGameState = 2;
	//////////////////////////////////////////////////////////////////////
	// Variables used for different mini games
	int iPictureID = 0;
	// WireMess Mini Game
	for(short i = 0; i < 4; i++)
	{
		bUsed[i] = false;
		bSlotFilled[i] = false;
	}
	bPieceSelected = false;
	// Circuit Puzzle Mini Game
	bGamePieceAttached = false;
	bStartPuzzle = true;
	// Component Mini Game
	sComponentTemp = 0;
	bC1 = false;
	bC2 = false;
	bC3 = false;
	bC4 = false;
	// Virus Attack Mini Game
	bK0 = false;
	bK1 = false;
	bK2 = false;
	bK3 = false;
	bK4 = false;
	bK5 = false;
	bK6 = false;
	bK7 = false;
	bK8 = false;
	bK9 = false;
	//////////////////////////////////////////////////////////////////////

	sSuccess = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\gameWin.png", D3DXVECTOR3(512, 384, 0), 1.0f);
	sOutOfTime = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\timeUp.png", D3DXVECTOR3(512, 384, 0), 1.0f);
	sYouFailed = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\gameLose.png", D3DXVECTOR3(512, 384, 0), 1.0f);

	// Switch case based on the game ID
	switch(sGameID)
	{
	case PICKFOUR:
		// PICK FOUR PUZZLE
		iPictureID = (int)(rand() % 2);
		sPuzzleScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\pickFourBG1.png", D3DXVECTOR3(512, 384, 0), 1.0f);
		if(iPictureID == 0)
		{
			sBrokenPic = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\circuitBroken.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			sGoodPic1 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\circuit.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			sGoodPic2 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\circuit.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\circuit.png", D3DXVECTOR3(0, 0, 0), 1.0f);
		}
		else if(iPictureID == 1)
		{
			sBrokenPic = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\codeBad.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			sGoodPic1 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\code.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			sGoodPic2 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\code.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\code.png", D3DXVECTOR3(0, 0, 0), 1.0f);
		}
		else
		{
			sBrokenPic = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\wireBad.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			sGoodPic1 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\wire.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			sGoodPic2 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\wire.png", D3DXVECTOR3(0, 0, 0), 1.0f);
			iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\wire.png", D3DXVECTOR3(0, 0, 0), 1.0f);
		}
		// Set up the positions
		vecCircuitPos[0] = D3DXVECTOR3(200, 500, 0);
		vecCircuitPos[1] = D3DXVECTOR3(400, 500, 0);
		vecCircuitPos[2] = D3DXVECTOR3(600, 500, 0);
		vecCircuitPos[3] = D3DXVECTOR3(800, 500, 0);
		for(short j = sBrokenPic; j <= iMaxSprite; j++)
		{
			int iChoice = (int)(rand() % 4);
			if(!bUsed[iChoice])
			{
				m_pSpriteManager->ModifySpritePos(j, vecCircuitPos[iChoice].x, vecCircuitPos[iChoice].y);
				bUsed[iChoice] = true;
			}
			else
				j--;
		}
		// Set the timer for 30 seconds
		lTotalTime = 1 * 30 * 1000;
		break;
	case EIGHTPIECE:
		// EIGHT PIECE PUZZLE
		iPictureID = (int)(rand() % 1);
		sPuzzleScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideGameBackground.png", D3DXVECTOR3(512, 384, 0), 1.0f);
		if(iPictureID == 0)
		{
			sCompletePicReference = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\completePic.png", D3DXVECTOR3(710, 440, 0), 0.75f);
			BoardPieces[0][0].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite1.png", D3DXVECTOR3(200, 310, 0), 0.5f);
			BoardPieces[0][1].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite2.png", D3DXVECTOR3(325, 310, 0), 0.5f);
			BoardPieces[0][2].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite3.png", D3DXVECTOR3(450, 310, 0), 0.5f);
			BoardPieces[1][0].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite4.png", D3DXVECTOR3(200, 435, 0), 0.5f);
			BoardPieces[1][1].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite5.png", D3DXVECTOR3(325, 435, 0), 0.5f);
			BoardPieces[1][2].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite6.png", D3DXVECTOR3(450, 435, 0), 0.5f);
			BoardPieces[2][0].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite7.png", D3DXVECTOR3(200, 560, 0), 0.5f);
			BoardPieces[2][1].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite8.png", D3DXVECTOR3(325, 560, 0), 0.5f);
			BoardPieces[2][2].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\slideSprite9.png", D3DXVECTOR3(450, 560, 0), 0.5f);
		}
		else
		{
			sCompletePicReference = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\robot.jpeg", D3DXVECTOR3(710, 380, 0), 0.75f);
			BoardPieces[0][0].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide2.tga", D3DXVECTOR3(200, 250, 0), 0.5f);
			BoardPieces[0][1].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide3.tga", D3DXVECTOR3(325, 250, 0), 0.5f);
			BoardPieces[0][2].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide4.tga", D3DXVECTOR3(450, 250, 0), 0.5f);
			BoardPieces[1][0].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide5.tga", D3DXVECTOR3(200, 375, 0), 0.5f);
			BoardPieces[1][1].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide6.tga", D3DXVECTOR3(325, 375, 0), 0.5f);
			BoardPieces[1][2].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide7.tga", D3DXVECTOR3(450, 375, 0), 0.5f);
			BoardPieces[2][0].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide8.tga", D3DXVECTOR3(200, 500, 0), 0.5f);
			BoardPieces[2][1].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide9.tga", D3DXVECTOR3(325, 500, 0), 0.5f);
			BoardPieces[2][2].sSlotID = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\SlideGame2\\slide1.tga", D3DXVECTOR3(450, 500, 0), 0.5f);
		}
		// Set up the positions of each slot
		BoardPieces[0][0].vecPos = D3DXVECTOR3(200, 310, 0);
		BoardPieces[0][1].vecPos = D3DXVECTOR3(325, 310, 0);
		BoardPieces[0][2].vecPos = D3DXVECTOR3(450, 310, 0);
		BoardPieces[1][0].vecPos = D3DXVECTOR3(200, 435, 0);
		BoardPieces[1][1].vecPos = D3DXVECTOR3(325, 435, 0);
		BoardPieces[1][2].vecPos = D3DXVECTOR3(450, 435, 0);
		BoardPieces[2][0].vecPos = D3DXVECTOR3(200, 560, 0);
		BoardPieces[2][1].vecPos = D3DXVECTOR3(325, 560, 0);
		BoardPieces[2][2].vecPos = D3DXVECTOR3(450, 560, 0);
		// Set all the slots to initially be false except the last one
		for(short i = 0; i < 3; i++)
		{
			for(short j = 0; j < 3; j++)
			{
				BoardPieces[i][j].bEmpty = false;
				if(i == 2 && j ==2)
					BoardPieces[i][j].bEmpty = true;
			}
		}
		// Set up the IDs
		BoardPieces[0][0].sPieceID = BoardPieces[1][2].sSlotID;
		BoardPieces[0][1].sPieceID = BoardPieces[2][0].sSlotID;
		BoardPieces[0][2].sPieceID = BoardPieces[0][1].sSlotID;
		BoardPieces[1][0].sPieceID = BoardPieces[1][0].sSlotID;
		BoardPieces[1][1].sPieceID = BoardPieces[2][1].sSlotID;
		BoardPieces[1][2].sPieceID = BoardPieces[0][2].sSlotID;
		BoardPieces[2][0].sPieceID = BoardPieces[1][1].sSlotID;
		BoardPieces[2][1].sPieceID = BoardPieces[0][0].sSlotID;
		BoardPieces[2][2].sPieceID = BoardPieces[2][2].sSlotID;
		iMaxSprite = BoardPieces[2][2].sSlotID;

		// Set up the pieces(HARDCODED GAME)
		m_pSpriteManager->ModifySpritePos(BoardPieces[0][0].sPieceID, BoardPieces[0][0].vecPos.x, BoardPieces[0][0].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[0][1].sPieceID, BoardPieces[0][1].vecPos.x, BoardPieces[0][1].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[0][2].sPieceID, BoardPieces[0][2].vecPos.x, BoardPieces[0][2].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[1][0].sPieceID, BoardPieces[1][0].vecPos.x, BoardPieces[1][0].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[1][1].sPieceID, BoardPieces[1][1].vecPos.x, BoardPieces[1][1].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[1][2].sPieceID, BoardPieces[1][2].vecPos.x, BoardPieces[1][2].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[2][0].sPieceID, BoardPieces[2][0].vecPos.x, BoardPieces[2][0].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[2][1].sPieceID, BoardPieces[2][1].vecPos.x, BoardPieces[2][1].vecPos.y);
		m_pSpriteManager->ModifySpritePos(BoardPieces[2][2].sPieceID, BoardPieces[2][2].vecPos.x, BoardPieces[2][2].vecPos.y);

		// Set the timer for 3 minutes
		lTotalTime = 3 * 60 * 1000;
		break;
	case CIRCUITMAZE:
		// CIRCUIT PUZZLE
		sPuzzleScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\CircuitPuzzle\\terminalBackground.png", D3DXVECTOR3(512, 384, 0), 1.0f);
		sCircuit = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\CircuitPuzzle\\ElecTexture.png", D3DXVECTOR3(525, 475, 0), 1.0f);
		sRedLight = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\CircuitPuzzle\\RedLight.png", D3DXVECTOR3(330, 300, 0), 0.3f);
		iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\CircuitPuzzle\\GreenLight.png", D3DXVECTOR3(330, 300, 0), 0.3f);

		// Set the timer for 20 seconds
		lTotalTime = 1 * 20 * 1000;
		break;
	case VIRUSATTACK:
		// Virus Attack Mini Game
		sPuzzleScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Terminal.png",D3DXVECTOR3(512, 595, 0), 0.4f);
		sMatrball = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\matrball.png",D3DXVECTOR3(512, 675, 0), 0.6f);
		sPlatform = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Platform.png",D3DXVECTOR3(450, 750, 0), 0.5f);
		sVirus0 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(512, 150, 0), 0.5f);
		sVirus1 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(300, 100, 0), 0.4f);
		sVirus2 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(700, 300, 0), 0.3f);
		sVirus3 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(912, 150, 0), 0.2f);
		sVirus4 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(400, 450, 0), 0.1f);
		sVirus5 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(725, 485, 0), 0.6f);
		sVirus6 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(100, 250, 0), 0.5f);
		sVirus7 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(100, 475, 0), 0.4f);
		sVirus8 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(315, 300, 0), 0.3f);
		sVirus9 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Virus.png",D3DXVECTOR3(700, 90, 0), 0.5f);
		sScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\terminalBackground.png", D3DXVECTOR3(-512, -384, 0), 1.0f);
		sStop = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\stop.png", D3DXVECTOR3(-512, -384, 0), 0.5f);
		iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\VirusAttackMiniGame\\Target.png",D3DXVECTOR3(525, 485, 0), 0.3f);

		// Set the timer for 1 minute
		lTotalTime = 1 * 60 * 1000;
		break;
	case POWERCHARGE:
		// POWER CHARGE
		sPuzzleScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\powerChargeBackground.png", D3DXVECTOR3(512, 384, 0), 1.0f);
		sChargeStation1 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\chargingBar.png", D3DXVECTOR3(275, 425, 0), 0.7f);
		sChargeStation2 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\chargingBar.png", D3DXVECTOR3(675, 425, 0), 0.7f);
		sRed[0] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\droppingEnergy.png", D3DXVECTOR3(300, 300, 0), 1.0f);
		sRed[1] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\droppingEnergy.png", D3DXVECTOR3(300, 360, 0), 1.0f);
		sRed[2] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\droppingEnergy.png", D3DXVECTOR3(300, 420, 0), 1.0f);
		sRed[3] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\droppingEnergy.png", D3DXVECTOR3(300, 480, 0), 1.0f);
		sRed[4] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\droppingEnergy.png", D3DXVECTOR3(300, 540, 0), 1.0f);
		sGreen[0] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\chargingEnergy.png", D3DXVECTOR3(-100, -100, 0), 1.0f);
		sGreen[1] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\chargingEnergy.png", D3DXVECTOR3(-100, -100, 0), 1.0f);
		sGreen[2] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\chargingEnergy.png", D3DXVECTOR3(-100, -100, 0), 1.0f);
		sGreen[3] = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\chargingEnergy.png", D3DXVECTOR3(-100, -100, 0), 1.0f);
		iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\PowerChargeMGSprites\\chargingEnergy.png", D3DXVECTOR3(-100, -100, 0), 1.0f);
		// Set up the positions
		vecOutPos = D3DXVECTOR3(-100, -100, 0);
		vecRedPos[0] = D3DXVECTOR3(300, 300, 0);
		vecRedPos[1] = D3DXVECTOR3(300, 360, 0);
		vecRedPos[2] = D3DXVECTOR3(300, 420, 0);
		vecRedPos[3] = D3DXVECTOR3(300, 480, 0);
		vecRedPos[4] = D3DXVECTOR3(300, 540, 0);
		vecGreenPos[0] = D3DXVECTOR3(700, 300, 0);
		vecGreenPos[1] = D3DXVECTOR3(700, 360, 0);
		vecGreenPos[2] = D3DXVECTOR3(700, 420, 0);
		vecGreenPos[3] = D3DXVECTOR3(700, 480, 0);
		vecGreenPos[4] = D3DXVECTOR3(700, 540, 0);
		// Set up the difficulty and time to 10 seconds
		sDifficulty = 10;
		lTotalTime = 1 * 20 * 1000;
		break;
	case WIREMESS:
		// WIREMESS PUZZLE
		sPuzzleScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessBackground.png", D3DXVECTOR3(512, 384, 0), 1.0f);
		sTopPieceBlue = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessBlueWireTop.png", D3DXVECTOR3(285, 250, 0), 0.5f);
		sTopPieceGreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessGreenWireTop.png", D3DXVECTOR3(415, 250, 0), 0.5f);
		sTopPieceRed = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessRedWireTop.png", D3DXVECTOR3(560, 250, 0), 0.5f);
		sTopPieceYellow = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessYellowWireTop.png", D3DXVECTOR3(715, 250, 0), 0.5f);
		sWire1 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessBlankSpace.png", D3DXVECTOR3(285, 605, 0), 0.5f);
		sWire2 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessBlankSpace.png", D3DXVECTOR3(415, 605, 0), 0.5f);
		sWire3 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessBlankSpace.png", D3DXVECTOR3(560, 605, 0), 0.5f);
		sWire4 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessBlankSpace.png", D3DXVECTOR3(715, 605, 0), 0.5f);
		sWire5 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessBlueWire.png", D3DXVECTOR3(285, 680, 0), 0.5f);
		sWire6 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessGreenWire.png", D3DXVECTOR3(415, 680, 0), 0.5f);
		sWire7 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessRedWire.png", D3DXVECTOR3(560, 680, 0), 0.5f);
		sWire8 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\wireMessYellowWire.png", D3DXVECTOR3(715, 680, 0), 0.5f);
		iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\miniGameWireMessSprites\\minigameWireMess.png", D3DXVECTOR3(500, 420, 0), 1.0f);

		// Set up the top positions
		vecCircuitPos[0] = D3DXVECTOR3(285, 280, 0);
		vecCircuitPos[1] = D3DXVECTOR3(415, 280, 0);
		vecCircuitPos[2] = D3DXVECTOR3(560, 280, 0);
		vecCircuitPos[3] = D3DXVECTOR3(715, 280, 0);
		// Randomly choose a position for the colors
		for(short i = sTopPieceBlue; i <= sTopPieceYellow; i++)
		{
			int iChoice = (int)(rand() % 4);
			if(!bUsed[iChoice])
			{
				m_pSpriteManager->ModifySpritePos(i, vecCircuitPos[iChoice].x, vecCircuitPos[iChoice].y);
				sColorID[iChoice] = i;
				bUsed[iChoice] = true;
			}
			else
				i--;
		}
		// Set up the positions of each slot
		WireLayout[0][0].vecPos = D3DXVECTOR3(285, 605, 0);
		WireLayout[0][1].vecPos = D3DXVECTOR3(415, 605, 0);
		WireLayout[0][2].vecPos = D3DXVECTOR3(560, 605, 0);
		WireLayout[0][3].vecPos = D3DXVECTOR3(715, 605, 0);
		WireLayout[1][0].vecPos = D3DXVECTOR3(285, 680, 0);
		WireLayout[1][1].vecPos = D3DXVECTOR3(415, 680, 0);
		WireLayout[1][2].vecPos = D3DXVECTOR3(560, 680, 0);
		WireLayout[1][3].vecPos = D3DXVECTOR3(715, 680, 0);

		// Set up the IDs for specific wire mess (HARDCODED GAME)
		WireLayout[0][0].sWireID = sColorID[3];
		WireLayout[0][1].sWireID = sColorID[2];
		WireLayout[0][2].sWireID = sColorID[0];
		WireLayout[0][3].sWireID = sColorID[1];

		// Set up the IDs for the pieces
		WireLayout[1][0].sPieceID = sTopPieceBlue;
		WireLayout[1][1].sPieceID = sTopPieceGreen;
		WireLayout[1][2].sPieceID = sTopPieceRed;
		WireLayout[1][3].sPieceID = sTopPieceYellow;
		// Set the timer to 30 seconds
		lTotalTime = 1 * 30 * 1000;
		break;
	case COMPONENTS:
		// Components Mini Game Puzzle
		sPuzzleScreen = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\componentMiniGameBackground.png",D3DXVECTOR3(512, 384, 0), 1.0f);
		sComponentBoard = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Component Board.png", D3DXVECTOR3(400, 500, 0), 0.5f);
		sComponent1 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Component1.png", D3DXVECTOR3(250, 300, 0), 0.9f);
		sComponent2 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Component2.png", D3DXVECTOR3(350, 300, 0), 0.5f);
		sComponent3 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Component3.png", D3DXVECTOR3(450, 300, 0), 0.8f);
		sComponent4 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Component4.png", D3DXVECTOR3(550, 300, 0), 0.9f);
		sComponent5 = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Component5.png", D3DXVECTOR3(650, 300, 0), 0.8f);
		sSwitch = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Switch.png", D3DXVECTOR3(140, 500, 0), 0.3f);
		iMaxSprite = m_pSpriteManager->LoadSprite("PuzzleDemoSprites\\ComponentMiniGame\\Component6.png", D3DXVECTOR3(750, 300, 0), 0.9f);

		// Set the timer for 45 seconds
		lTotalTime = 1 * 45 * 1000;
		break;
	}
}

void MiniGame::Update(HWND hWnd, DirectInput* m_pDirectInputIn)
{
	//Update audio
	m_pSound->Update();

	// Set the direct input pointer
	m_pDirectInput = m_pDirectInputIn;

	if(bGameOver || bGameWon || bSuccess || bOutOfTime || bYouFailed)
	{
		bTimer = false;
	}
	else
	{
		bTimer = true;
	}
	if(bTimer)
	{
		// Update the timer
		lCurrentTime = (LONG)timeGetTime();
		lMilliseconds = lCurrentTime - lStartTime;
		if(!bGameWon || !bGameOver)
		{
			if(lMilliseconds > 1000)
			{
				lTotalTime -= 1000;
				sClickTimer++;
				lStartTime = (LONG)timeGetTime();
			}
		}
	}
	else
	{
		sClickTimer++;
	}
	if( lTotalTime > -1 )
	{
		m_pText->SetTimer(lTotalTime);
	}
	else
	{
		bGameOver = true;
	}

	// Switch for mini games
	switch(sGameID)
	{
	case PICKFOUR:
		MiniGame::PickFourPuzzle(hWnd);
		break;
	case EIGHTPIECE:
		MiniGame::EightPiecePuzzle(hWnd);
		break;
	case CIRCUITMAZE:
		MiniGame::CircuitPuzzle(hWnd);
		break;
	case VIRUSATTACK:
		MiniGame::VirusAttack(hWnd);
		break;
	case POWERCHARGE:
		MiniGame::PowerChargePuzzle(hWnd);
		break;
	case WIREMESS:
		MiniGame::WireMessPuzzle(hWnd);
		break;
	case COMPONENTS:
		MiniGame::ComponentPuzzle(hWnd);
		break;
	}
}

void MiniGame::Render(IDirect3DDevice9* m_pD3DDevice)
{
	for(short i = sPuzzleScreen; i <= iMaxSprite; i++)
		m_pSpriteManager->DrawSprite(i);

	if(bSuccess)
	{
		m_pSpriteManager->DrawSprite(sSuccess);
	}

	if(bOutOfTime)
	{
		m_pSpriteManager->DrawSprite(sOutOfTime);
	}

	if(bYouFailed)
	{
		m_pSpriteManager->DrawSprite(sYouFailed);
	}

	m_pText->RenderTime();
}

void MiniGame::PickFourPuzzle(HWND hWnd)
{
	m_pDirectInput->Update(hWnd);

	// CHOICES
	if(!bGameOver)
	{
		sComChoice = sBrokenPic;
		if(m_pDirectInput->CheckMouseButtons(0)&& sClickTimer > 1)
		{
			// CORRECT PIC
			if(m_pSpriteManager->SpriteCollision(sBrokenPic, m_pDirectInput->currentMousePos)) //&& sClickTimer > 1)
			{
				if(!bSoundLoaded)
				{
					m_pSound->PickFourButtonClickSFX();
					bSoundLoaded = true;
				}
				sPlayerChoice = sBrokenPic;
				sClickTimer = 0;
				bGameOver = true;
			}
			else
				bSoundLoaded = false;
			// WRONG PIC
			if(m_pSpriteManager->SpriteCollision(sGoodPic1, m_pDirectInput->currentMousePos)) //&& sClickTimer > 1)
			{
				if(!bSoundLoaded)
				{
					m_pSound->PickFourButtonClickSFX();
					bSoundLoaded = true;
				}
				sPlayerChoice = sGoodPic1;
				sClickTimer = 0;
				bGameOver = true;
			}
			else
				bSoundLoaded = false;
			// WRONG PIC
			if(m_pSpriteManager->SpriteCollision(sGoodPic2, m_pDirectInput->currentMousePos)) //&& sClickTimer > 1)
			{
				if(!bSoundLoaded)
				{
					m_pSound->PickFourButtonClickSFX();
					bSoundLoaded = true;
				}
				sPlayerChoice = sGoodPic2;
				sClickTimer = 0;
				bGameOver = true;
			}
			else
				bSoundLoaded = false;
			// WRONG PIC
			if(m_pSpriteManager->SpriteCollision(iMaxSprite, m_pDirectInput->currentMousePos)) //&& sClickTimer > 1)
			{
				if(!bSoundLoaded)
				{
					m_pSound->PickFourButtonClickSFX();
					bSoundLoaded = true;
				}
				sPlayerChoice = iMaxSprite;
				sClickTimer = 0;
				bGameOver = true;
			}
			else
				bSoundLoaded = false;
		}
	}
	else
	{
		// Did player win the game?
		if(sPlayerChoice == sComChoice)
		{
			bSuccess = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sSuccess, m_pDirectInput->currentMousePos))
				{
					bSuccess = false;
					sClickTimer = 0;
					bGameWon = true;
					bGameOver = false;
					sGameState = 1;
					m_pModelManager->ModifyModelPos(sTerminal, -50, 0, 0);
				}
			}
		}
		else if(lTotalTime < 0)
		{
			bOutOfTime = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sOutOfTime, m_pDirectInput->currentMousePos))
				{
					bOutOfTime = false;
					bGameOver = false;
					sLosses++;
					sClickTimer = 0;
					//reset timer
					lTotalTime = 1 * 30 * 1000;
				}
			}
		}
		else
		{
			bYouFailed = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sYouFailed, m_pDirectInput->currentMousePos))
				{
					bYouFailed = false;
					bGameOver = false;
					sLosses++;
					sClickTimer = 0;
				}
			}
		}
	}
	if(sLosses == 2)
	{
		sGameState = 1;
	}
}

void MiniGame::EightPiecePuzzle(HWND hWnd)
{
	// Update direct input
	m_pDirectInput->Update(hWnd);

	// Needed to check if all pieces are correct
	bool bBrokeOut;

	if(!bGameOver)
	{
		// Check collision between the pieces
		// If the piece is able to go to the empty
		//  slot, switch the piece and empty slot
		if(sClickTimer > 1 && m_pDirectInput->CheckMouseButtons(0))
		{
			// Go through the pieces to find out which one was chosen and where to move it (if it can)
			for(int i = 0; i < 3; i++)
			{
				for(int j = 0; j < 3; j++)
				{
					if(m_pSpriteManager->SpriteCollision(BoardPieces[i][j].sPieceID, m_pDirectInput->currentMousePos))
					{
						if(!bSoundLoaded)
						{
							m_pSound->SlideEightPieceSelectSFX();
							bSoundLoaded = true;
						}
						if(BoardPieces[i][j].sPieceID != BoardPieces[2][2].sSlotID)
						{
							// PIECE LEFT OF CHOICE
							if(BoardPieces[i][j - 1].bEmpty && (j - 1) > -1)
							{
								m_pSpriteManager->ModifySpritePos(BoardPieces[i][j].sPieceID, BoardPieces[i][j - 1].vecPos.x, BoardPieces[i][j - 1].vecPos.y);
								BoardPieces[i][j - 1].bEmpty = false;
								m_pSpriteManager->ModifySpritePos(BoardPieces[i][j - 1].sPieceID, BoardPieces[i][j].vecPos.x, BoardPieces[i][j].vecPos.y);
								BoardPieces[i][j].bEmpty = true;
								sTemp = BoardPieces[i][j - 1].sPieceID;
								BoardPieces[i][j - 1].sPieceID = BoardPieces[i][j].sPieceID;
								BoardPieces[i][j].sPieceID = sTemp;
								sClickTimer = 0;
								break;
							}
							// PIECE RIGHT OF CHOICE
							else if(BoardPieces[i][j + 1].bEmpty && (j + 1) < 3)
							{
								m_pSpriteManager->ModifySpritePos(BoardPieces[i][j].sPieceID, BoardPieces[i][j + 1].vecPos.x, BoardPieces[i][j +1].vecPos.y);
								BoardPieces[i][j + 1].bEmpty = false;
								m_pSpriteManager->ModifySpritePos(BoardPieces[i][j + 1].sPieceID, BoardPieces[i][j].vecPos.x, BoardPieces[i][j].vecPos.y);
								BoardPieces[i][j].bEmpty = true;
								sTemp = BoardPieces[i][j + 1].sPieceID;
								BoardPieces[i][j + 1].sPieceID = BoardPieces[i][j].sPieceID;
								BoardPieces[i][j].sPieceID = sTemp;
								sClickTimer = 0;
								break;
							}
							// PIECE ABOVE CHOICE
							else if(BoardPieces[i - 1][j].bEmpty && (i - 1) > -1)
							{
								m_pSpriteManager->ModifySpritePos(BoardPieces[i][j].sPieceID, BoardPieces[i - 1][j].vecPos.x, BoardPieces[i - 1][j].vecPos.y);
								BoardPieces[i - 1][j].bEmpty = false;
								m_pSpriteManager->ModifySpritePos(BoardPieces[i - 1][j].sPieceID, BoardPieces[i][j].vecPos.x, BoardPieces[i][j].vecPos.y);
								BoardPieces[i][j].bEmpty = true;
								sTemp = BoardPieces[i - 1][j].sPieceID;
								BoardPieces[i - 1][j].sPieceID = BoardPieces[i][j].sPieceID;
								BoardPieces[i][j].sPieceID = sTemp;
								sClickTimer = 0;
								break;
							}
							// PIECE UNDER CHOICE
							else if(BoardPieces[i + 1][j].bEmpty && (i + 1) < 3)
							{
								m_pSpriteManager->ModifySpritePos(BoardPieces[i][j].sPieceID, BoardPieces[i + 1][j].vecPos.x, BoardPieces[i + 1][j].vecPos.y);
								BoardPieces[i + 1][j].bEmpty = false;
								m_pSpriteManager->ModifySpritePos(BoardPieces[i + 1][j].sPieceID, BoardPieces[i][j].vecPos.x, BoardPieces[i][j].vecPos.y);
								BoardPieces[i][j].bEmpty = true;
								sTemp = BoardPieces[i + 1][j].sPieceID;
								BoardPieces[i + 1][j].sPieceID = BoardPieces[i][j].sPieceID;
								BoardPieces[i][j].sPieceID = sTemp;
								sClickTimer = 0;
								break;
							}
						}
					}
					else
						bSoundLoaded = false;
				}
			}
		}
		// Check if the player has one by checking all IDs
		// making sure that they match up
		for(int i = 0; i < 3; i++)
		{
			for(int j = 0; j < 3; j++)
			{
				if(BoardPieces[i][j].sSlotID != BoardPieces[i][j].sPieceID)
				{
					bGameWon = false;
					bGameOver = false;
					bBrokeOut = true;
					break;
				}
				else
				{
					bGameWon = true;
					bGameOver = true;
					bBrokeOut = false;
				}
			}
			if(bBrokeOut)
				break;
		}
		//// TESTING PURPOSES
		//if(m_pDirectInput->CheckKeyboard(DIK_F) && m_pDirectInput->CheckKeyboard(DIK_U))
		//{
		//	bGameOver = true;
		//	bGameWon = true;
		//}
	}
	// Did player win the game?
	else if(lTotalTime < 0)
	{
		bOutOfTime = true;
		if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
		{
			if(m_pSpriteManager->SpriteCollision(sOutOfTime, m_pDirectInput->currentMousePos))
			{
				bOutOfTime = false;
				bGameOver = false;
				sLosses++;
				sClickTimer = 0;
				//reset timer
				lTotalTime = 3 * 60 * 1000;
			}
		}
	}
	else if(bGameWon)
	{
		bSuccess = true;
		if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
		{
			if(m_pSpriteManager->SpriteCollision(sSuccess, m_pDirectInput->currentMousePos))
			{
				m_pModelManager->ModifyModelPos(sTerminal, -50, 0, 0);
				bSuccess = false;
				sGameState = 1;
				sClickTimer = 0;
			}
		}
	}

	if(sLosses == 1)
	{
		sGameState = 1;
	}
}

// INDIVIDUAL MINI GAME UPDATES
void MiniGame::CircuitPuzzle(HWND hWnd)
{
	// Update direct input
	m_pDirectInput->Update(hWnd);

	if(bStartPuzzle == true)
	{
		//Set the lights to their starting point
		m_pSpriteManager->ModifySpritePos( sRedLight, 330, 300 );
		m_pSpriteManager->ModifySpritePos( iMaxSprite, -20, -20 );

		// Set the x y for switching the light & activating the puzzle walls
		if( m_pDirectInput->currentMousePos.x >= 320.0 && m_pDirectInput->currentMousePos.x <= 350.0 &&
			m_pDirectInput->currentMousePos.y >= 310.0 && m_pDirectInput->currentMousePos.y <= 335.0 )
		{
			bGamePieceAttached = true;
		}
	}
	if(bGamePieceAttached && !bSuccess)
	{
		//Remove the cursor so the use cant see it, and it dont block the Game Piece
		//SetCursor(NULL);
		// Switch the red light and the green light so user knows the board is active
		m_pSpriteManager->ModifySpritePos( sRedLight, -20, -20 );
		m_pSpriteManager->ModifySpritePos( iMaxSprite, 330, 300 );

		// Check if the cursor is still inside of the pathway
		if( m_pDirectInput->currentMousePos.x >= 308.0 && m_pDirectInput->currentMousePos.x <= 746.0 &&
			m_pDirectInput->currentMousePos.y >= 289.0 && m_pDirectInput->currentMousePos.y <= 350.0 )
		{}
		else if(m_pDirectInput->currentMousePos.x >= 679.0 && m_pDirectInput->currentMousePos.x <= 746.0 &&
			m_pDirectInput->currentMousePos.y >= 289.0 && m_pDirectInput->currentMousePos.y <= 676.0 )
		{}
		else if(m_pDirectInput->currentMousePos.x >= 349.0 && m_pDirectInput->currentMousePos.x <= 746.0 &&
			m_pDirectInput->currentMousePos.y >= 636.0 && m_pDirectInput->currentMousePos.y <= 676.0 )
		{}
		else if(m_pDirectInput->currentMousePos.x >= 349.0 && m_pDirectInput->currentMousePos.x <= 381.0 &&
			m_pDirectInput->currentMousePos.y >= 515.0 && m_pDirectInput->currentMousePos.y <= 676.0 )
		{}
		else if(m_pDirectInput->currentMousePos.x >= 349.0 && m_pDirectInput->currentMousePos.x <= 572.0 &&
			m_pDirectInput->currentMousePos.y >= 515.0 && m_pDirectInput->currentMousePos.y <= 533.0 )
		{}
		else if(m_pDirectInput->currentMousePos.x >= 572.0 && m_pDirectInput->currentMousePos.x <= 575.0 &&
			m_pDirectInput->currentMousePos.y >= 515.0 && m_pDirectInput->currentMousePos.y <= 533.0 )
		{
			bGamePieceAttached = false;
			bSuccess = true;
			bGameWon = true;
		}
		else
		{
			if(!bYouFailed)
			{
				m_pSound->CircuitWallCollisionSFX();
			}
			bYouFailed = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sYouFailed, m_pDirectInput->currentMousePos))
				{
					bYouFailed = false;
					bStartPuzzle = true;
					bGamePieceAttached = false;
					m_pSpriteManager->ModifySpritePos( sRedLight, 330, 300 );
					m_pSpriteManager->ModifySpritePos( iMaxSprite, -20, -20 );
					sLosses++;
					sClickTimer = 0;
					lTotalTime = 1 * 20 * 1000;
				}
			}
		}
	}
	if(bSuccess)
	{
		if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
		{
			if(m_pSpriteManager->SpriteCollision(sSuccess, m_pDirectInput->currentMousePos))
			{
				bSuccess = false;
				sClickTimer = 0;
				bStartPuzzle = false;
				m_pModelManager->ModifyModelPos(sTerminal, -50, 0, 0);
				sGameState = 1;
			}
		}
	}
	if(lTotalTime < 0)
	{
		bOutOfTime = true;
		if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
		{
			if(m_pSpriteManager->SpriteCollision(sOutOfTime, m_pDirectInput->currentMousePos))
			{
				bOutOfTime = false;
				bStartPuzzle = true;
				bGamePieceAttached = false;
				m_pSpriteManager->ModifySpritePos( sRedLight, 330, 300 );
				m_pSpriteManager->ModifySpritePos( iMaxSprite, -20, -20 );
				sLosses++;
				sClickTimer = 0;
				//reset timer
				lTotalTime = 1 * 20 * 1000;
			}
		}
	}

	if(sLosses == 3)
	{
		sGameState = 1;
	}
}

void MiniGame::PowerChargePuzzle(HWND hWnd)
{
	// Update direct input
	m_pDirectInput->Update(hWnd);

	if(!bGameOver)
	{
		if(m_pDirectInput->CheckKeyboard(DIK_UP))
		{
			if(!bKeyDown[DIK_UP])
			{
				sCounter += 2;
				bKeyDown[DIK_UP] = true;
			}
		}
		else
			bKeyDown[DIK_UP] = false;
		if(sClickTimer > 0)
		{
			sCounter -= sDifficulty;
			if(sCounter < 0)
				sCounter = 0;
			sClickTimer = 0;
		}
		if(sCounter < 5)
		{
			// ALL GREEN OUT
			for(short i = 0; i < 4; i++)
				m_pSpriteManager->ModifySpritePos(sGreen[i], vecOutPos.x, vecOutPos.y);
			m_pSpriteManager->ModifySpritePos(iMaxSprite, vecOutPos.x, vecOutPos.y);
			// ALL RED IN
			for(short i = 0; i < 5; i++)
				m_pSpriteManager->ModifySpritePos(sRed[i], vecRedPos[i].x, vecRedPos[i].y);
		}
		else if(sCounter < 7)
		{
			// ONE GREEN IN
			for(short i = 0; i < 4; i++)
				m_pSpriteManager->ModifySpritePos(sGreen[i], vecOutPos.x, vecOutPos.y);
			m_pSpriteManager->ModifySpritePos(iMaxSprite, vecGreenPos[4].x, vecGreenPos[4].y);
			// ONE RED OUT
			for(short i = 1; i < 5; i++)
				m_pSpriteManager->ModifySpritePos(sRed[i], vecRedPos[i].x, vecRedPos[i].y);
			m_pSpriteManager->ModifySpritePos(sRed[0], vecOutPos.x, vecOutPos.y);
		}
		else if(sCounter < 11)
		{
			// TWO GREEN IN, THREE OUT
			for(short i = 0; i < 3; i++)
				m_pSpriteManager->ModifySpritePos(sGreen[i], vecOutPos.x, vecOutPos.y);
			m_pSpriteManager->ModifySpritePos(iMaxSprite, vecGreenPos[4].x, vecGreenPos[4].y);
			m_pSpriteManager->ModifySpritePos(sGreen[3], vecGreenPos[3].x, vecGreenPos[3].y);
			// TWO RED OUT, THREE IN
			for(short i = 2; i < 5; i++)
				m_pSpriteManager->ModifySpritePos(sRed[i], vecRedPos[i].x, vecRedPos[i].y);
			m_pSpriteManager->ModifySpritePos(sRed[0], vecOutPos.x, vecOutPos.y);
			m_pSpriteManager->ModifySpritePos(sRed[1], vecOutPos.x, vecOutPos.y);
		}
		else if(sCounter < 19)
		{
			// THREE GREEN IN, TWO OUT
			for(short i = 0; i < 2; i++)
				m_pSpriteManager->ModifySpritePos(sGreen[i], vecOutPos.x, vecOutPos.y);
			m_pSpriteManager->ModifySpritePos(iMaxSprite, vecGreenPos[4].x, vecGreenPos[4].y);
			m_pSpriteManager->ModifySpritePos(sGreen[3], vecGreenPos[3].x, vecGreenPos[3].y);
			m_pSpriteManager->ModifySpritePos(sGreen[2], vecGreenPos[2].x, vecGreenPos[2].y);
			// THREE RED OUT, TWO IN
			for(short i = 3; i < 5; i++)
				m_pSpriteManager->ModifySpritePos(sRed[i], vecRedPos[i].x, vecRedPos[i].y);
			for(short i = 0; i < 3; i++)
				m_pSpriteManager->ModifySpritePos(sRed[i], vecOutPos.x, vecOutPos.y);
		}
		else if(sCounter < 25)
		{
			// FOUR GREEN IN, ONE OUT
			m_pSpriteManager->ModifySpritePos(sGreen[0], vecOutPos.x, vecOutPos.y);
			m_pSpriteManager->ModifySpritePos(iMaxSprite, vecGreenPos[4].x, vecGreenPos[4].y);
			for(short i = 3; i > 0; i--)
				m_pSpriteManager->ModifySpritePos(sGreen[i], vecGreenPos[i].x, vecGreenPos[i].y);
			// FOUR RED OUT, ONE IN
			m_pSpriteManager->ModifySpritePos(sRed[4], vecRedPos[4].x, vecRedPos[4].y);
			for(short i = 0; i < 4; i++)
				m_pSpriteManager->ModifySpritePos(sRed[i], vecOutPos.x, vecOutPos.y);
		}
		else
		{
			// ALL GREEN IN
			m_pSpriteManager->ModifySpritePos(iMaxSprite, vecGreenPos[4].x, vecGreenPos[4].y);
			for(short i = 3; i > -1; i--)
				m_pSpriteManager->ModifySpritePos(sGreen[i], vecGreenPos[i].x, vecGreenPos[i].y);
			// ALL RED OUT
			for(short i = 0; i < 5; i++)
				m_pSpriteManager->ModifySpritePos(sRed[i], vecOutPos.x, vecOutPos.y);
		}
		if(sCounter > 30)
			bGameOver = true;
	}
	else if(lTotalTime < 0)
	{
		bOutOfTime = true;
		if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
		{
			if(m_pSpriteManager->SpriteCollision(sOutOfTime, m_pDirectInput->currentMousePos))
			{
				bOutOfTime = false;
				bGameOver = false;
				sLosses++;
				sClickTimer = 0;
				//reset timer
				lTotalTime = 1 * 20 * 1000;
			}
		}
	}
	else
	{
		bSuccess = true;
		if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
		{
			if(m_pSpriteManager->SpriteCollision(sSuccess, m_pDirectInput->currentMousePos))
			{
				bSuccess = false;
				sClickTimer = 0;
				bGameWon = true;
				sGameState = 1;
				m_pModelManager->ModifyModelPos(sTerminal, -50, 0, 0);
			}
		}
	}
}

void MiniGame::WireMessPuzzle(HWND hWnd)
{
	// Update direct input
	m_pDirectInput->Update(hWnd);

	if(!bGameOver)
	{
		if(m_pDirectInput->CheckMouseButtons(0))
		{
			if(sClickTimer > 1)
			{
				if(!bPieceSelected)
				{
					if(m_pSpriteManager->SpriteCollision(sWire5, m_pDirectInput->currentMousePos))
					{
						sPiece = sWire5;
						bPieceSelected = true;
						sClickTimer = 0;
					}
					if(m_pSpriteManager->SpriteCollision(sWire6, m_pDirectInput->currentMousePos))
					{
						sPiece = sWire6;
						bPieceSelected = true;
						sClickTimer = 0;
					}
					if(m_pSpriteManager->SpriteCollision(sWire7, m_pDirectInput->currentMousePos))
					{
						sPiece = sWire7;
						bPieceSelected = true;
						sClickTimer = 0;
					}
					if(m_pSpriteManager->SpriteCollision(sWire8, m_pDirectInput->currentMousePos))
					{
						sPiece = sWire8;
						bPieceSelected = true;
						sClickTimer = 0;
					}
				}
				else
				{
					// SLOT 1
					if(m_pSpriteManager->SpriteCollision(sWire1, m_pDirectInput->currentMousePos))
					{
						if(!bSlotFilled[0])
						{
							m_pSpriteManager->ModifySpritePos(sPiece, WireLayout[0][0].vecPos.x, WireLayout[0][0].vecPos.y);
							WireLayout[1][sPiece - 12].sWireID = WireLayout[0][0].sWireID;
							bSlotFilled[0] = true;
							bPieceSelected = false;
							sClickTimer = 0;
						}
						else
						{
							bSlotFilled[0] = false;
						}
					}
					// SLOT 2
					if(m_pSpriteManager->SpriteCollision(sWire2, m_pDirectInput->currentMousePos))
					{
						if(!bSlotFilled[1])
						{
							m_pSpriteManager->ModifySpritePos(sPiece, WireLayout[0][1].vecPos.x, WireLayout[0][1].vecPos.y);
							WireLayout[1][sPiece - 12].sWireID = WireLayout[0][1].sWireID;
							bSlotFilled[1] = true;
							bPieceSelected = false;
							sClickTimer = 0;
						}
						else
						{
							bSlotFilled[1] = false;
						}
					}
					// SLOT 3
					if(m_pSpriteManager->SpriteCollision(sWire3, m_pDirectInput->currentMousePos))
					{
						if(!bSlotFilled[2])
						{
							m_pSpriteManager->ModifySpritePos(sPiece, WireLayout[0][2].vecPos.x, WireLayout[0][2].vecPos.y);
							WireLayout[1][sPiece - 12].sWireID = WireLayout[0][2].sWireID;
							bSlotFilled[2] = true;
							bPieceSelected = false;
							sClickTimer = 0;
						}
						else
						{
							bSlotFilled[2] = false;
						}
					}
					// SLOT 4
					if(m_pSpriteManager->SpriteCollision(sWire4, m_pDirectInput->currentMousePos))
					{
						if(!bSlotFilled[3])
						{
							m_pSpriteManager->ModifySpritePos(sPiece, WireLayout[0][3].vecPos.x, WireLayout[0][3].vecPos.y);
							WireLayout[1][sPiece - 12].sWireID = WireLayout[0][3].sWireID;
							bSlotFilled[3] = true;
							bPieceSelected = false;
							sClickTimer = 0;
						}
						else
						{
							bSlotFilled[3] = false;
						}
					}
				}
			}
		}
		if(bPieceSelected)
			m_pSpriteManager->ModifySpritePos(sPiece, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y);

		for(short i = 0; i < 4; i++)
		{
			if(bSlotFilled[i])
				bGameOver = true;
			else
			{
				bGameOver = false;
				break;
			}
		}
	}
	else
	{
		for(int i = 0; i < 4; i++)
		{
			if(WireLayout[1][i].sPieceID != WireLayout[1][i].sWireID)
			{
				bGameWon = false;
				break;
			}
			else
				bGameWon = true;
		}

		if(lTotalTime < 0)
		{
			//MessageBox(NULL, "Times Up", "Temporary", NULL);
			//bGameOver = false;
			//sLosses++;
			//// Reset timer
			//lTotalTime = 1 * 60 * 1000;
			bPieceSelected = false;
			bOutOfTime = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sOutOfTime, m_pDirectInput->currentMousePos))
				{
					bOutOfTime = false;
					bGameOver = false;
					sLosses++;
					sClickTimer = 0;
					//reset timer
					lTotalTime = 1 * 45 * 1000;
					for(int i = 0; i < 4; i++)
					{
						bSlotFilled[i] = false;
						WireLayout[1][i].sWireID = -1;
						m_pSpriteManager->ModifySpritePos(i + 12, WireLayout[1][i].vecPos.x, WireLayout[1][i].vecPos.y);
					}
				}
			}
		}
		else if(!bGameWon)
		{
			//MessageBox(NULL, "Incorrect!!", "Temporary", NULL);
			//bGameOver = false;
			//sLosses++;
			//// Reset time and positions
			//lTotalTime = 1 * 60 * 1000;
			//for(short i = 0; i < 4; i++)
			//{
			//	bSlotFilled[i] = false;
			//	WireLayout[1][i].sWireID = -1;
			//	m_pSpriteManager->ModifySpritePos(i + 9, WireLayout[1][i].vecPos.x, WireLayout[1][i].vecPos.y);
			//}

			bYouFailed = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sYouFailed, m_pDirectInput->currentMousePos))
				{
					bYouFailed = false;
					bGameOver = false;
					sLosses++;
					// Reset time and positions
					lTotalTime = 1 * 45 * 1000;
					for(int i = 0; i < 4; i++)
					{
						bSlotFilled[i] = false;
						WireLayout[1][i].sWireID = -1;
						m_pSpriteManager->ModifySpritePos(i + 12, WireLayout[1][i].vecPos.x, WireLayout[1][i].vecPos.y);
					}
					sClickTimer = 0;
				}
			}
		}
		else
		{
			bSuccess = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sSuccess, m_pDirectInput->currentMousePos))
				{
					bSuccess = false;
					sClickTimer = 0;
					m_pModelManager->ModifyModelPos(sTerminal, -50, 0, 0);
					sGameState = 1;
				}
			}
		}
		if(sLosses == 2)
			sGameState = 1;
	}
}

void MiniGame::ComponentPuzzle(HWND hWnd)
{
	// Update direct input
	m_pDirectInput->Update(hWnd);
	// Start the game
	if(!bGameOver)
	{
		// Check if the left mouse button was pressed
		if(m_pDirectInput->CheckMouseButtons(0))
		{
			/// Collision with all of the components
			if(m_pSpriteManager->SpriteCollision(sComponent1, m_pDirectInput->currentMousePos) && !bC1)
			{
				sComponentTemp = 1;
				sClickTimer = 0;
			}
			if(m_pSpriteManager->SpriteCollision(sComponent2, m_pDirectInput->currentMousePos) && !bC2)
			{
				sComponentTemp = 2;
				sClickTimer = 0;
			}
			if(m_pSpriteManager->SpriteCollision(sComponent3, m_pDirectInput->currentMousePos) && !bC3)
			{
				sComponentTemp = 3;
				sClickTimer = 0;
			}
			if(m_pSpriteManager->SpriteCollision(sComponent4, m_pDirectInput->currentMousePos))
			{
				sComponentTemp = 4;
				sClickTimer = 0;
			}
			if(m_pSpriteManager->SpriteCollision(sComponent5, m_pDirectInput->currentMousePos) && !bC4)
			{
				sComponentTemp = 5;
				sClickTimer = 0;
			}
			if(m_pSpriteManager->SpriteCollision(iMaxSprite, m_pDirectInput->currentMousePos))
			{
				sComponentTemp = 6;
				sClickTimer = 0;
			}
			/// Make each component move with the mouse
			if(sComponentTemp == 1)
			{
				m_pSpriteManager->ModifySpritePos(sComponent1, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y );
				// Check if the component is inside the placement
				if( m_pDirectInput->currentMousePos.x >= 397.0 && m_pDirectInput->currentMousePos.x <= 467.0 &&
					m_pDirectInput->currentMousePos.y >= 522.0 && m_pDirectInput->currentMousePos.y <= 562.0 )
				{
					m_pSpriteManager->ModifySpritePos( sComponent1, 437, 542 );
					sComponentTemp = 0;
					bC1 = true;
				}
			}
			if(sComponentTemp == 2)
			{
				m_pSpriteManager->ModifySpritePos(sComponent2, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y );
				if( m_pDirectInput->currentMousePos.x >= 590.0 && m_pDirectInput->currentMousePos.x <= 630.0 &&
					m_pDirectInput->currentMousePos.y >= 475.0 && m_pDirectInput->currentMousePos.y <= 575.0 )
				{
					m_pSpriteManager->ModifySpritePos( sComponent2, 610, 525 );
					sComponentTemp = 0;
					bC2 = true;
				}
			}
			if(sComponentTemp == 3)
			{
				m_pSpriteManager->ModifySpritePos(sComponent3, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y );
				if( m_pDirectInput->currentMousePos.x >= 420.0 && m_pDirectInput->currentMousePos.x <= 480.0 &&
					m_pDirectInput->currentMousePos.y >= 415.0 && m_pDirectInput->currentMousePos.y <= 455.0 )
				{
					m_pSpriteManager->ModifySpritePos( sComponent3, 450, 435 );
					sComponentTemp = 0;
					bC3 = true;
				}
			}
			if(sComponentTemp == 4)
			{
				m_pSpriteManager->ModifySpritePos(sComponent4, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y );
				if( m_pDirectInput->currentMousePos.x >= 280.0 && m_pDirectInput->currentMousePos.x <= 750.0 &&
					m_pDirectInput->currentMousePos.y >= 425.0 && m_pDirectInput->currentMousePos.y <= 620.0 )
				{
					m_pSpriteManager->ModifySpritePos( sComponent4, 550, 300 );
					sComponentTemp = 9;
					bGameOver = true;
				}
			}
			if(sComponentTemp == 5)
			{
				m_pSpriteManager->ModifySpritePos(sComponent5, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y );
				if( m_pDirectInput->currentMousePos.x >= 664.0 && m_pDirectInput->currentMousePos.x <= 724.0 &&
					m_pDirectInput->currentMousePos.y >= 472.0 && m_pDirectInput->currentMousePos.y <= 532.0 )
				{
					m_pSpriteManager->ModifySpritePos( sComponent5, 694, 502 );
					sComponentTemp = 0;
					bC4 = true;
				}
			}
			if(sComponentTemp == 6)
			{
				m_pSpriteManager->ModifySpritePos(iMaxSprite, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y );
				if( m_pDirectInput->currentMousePos.x >= 280.0 && m_pDirectInput->currentMousePos.x <= 750.0 &&
					m_pDirectInput->currentMousePos.y >= 425.0 && m_pDirectInput->currentMousePos.y <= 620.0 )
				{
					m_pSpriteManager->ModifySpritePos( iMaxSprite, 750, 300 );
					sComponentTemp = 9;
					bGameOver = true;
				}
			}
		}
		if(bC1 == true && bC2 == true && bC3 == true && bC4 == true && m_pSpriteManager->SpriteCollision(sSwitch, m_pDirectInput->currentMousePos))
			bGameOver = true;
	}
	if(bGameOver)
	{
		if(bC1 == true && bC2 == true && bC3 == true && bC4 == true)
		{
			bSuccess = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sSuccess, m_pDirectInput->currentMousePos))
				{
					bSuccess = false;
					sClickTimer = 0;
					bGameWon = true;
					bGameOver = false;
					bC1 = false; bC2 = false; bC3 = false; bC4 = false;
					sGameState = 1;
					m_pModelManager->ModifyModelPos(sTerminal, -50, 0, 0);
				}
			}
		}
		else if(lTotalTime < 0)
		{
			bOutOfTime = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sOutOfTime, m_pDirectInput->currentMousePos))
				{
					bOutOfTime = false;
					bGameOver = false;
					bC1 = false; bC2 = false; bC3 = false; bC4 = false;
					sGameState = 1;
					sClickTimer = 0;
				}
			}
		}
		else if(sComponentTemp == 9)
		{
			bYouFailed = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sYouFailed, m_pDirectInput->currentMousePos))
				{
					bYouFailed = false;
					bGameOver = false;
					bC1 = false; bC2 = false; bC3 = false; bC4 = false;
					sGameState = 1;
					sClickTimer = 0;
				}
			}
		}
	}
}

void MiniGame::VirusAttack(HWND hWnd)
{
	// Update direct input
	m_pDirectInput->Update(hWnd);
	// Set the Kill Counter back to 0

	// Start the game
	if(!bGameOver)
	{
		// Move the Virus around the screen
		m_pSpriteManager->ModifySpriteRot(sVirus0, 0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus1, 0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus2, -0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus3, 0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus4, -0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus5, -0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus6, -0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus7, 0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus8, -0.0005f);
		m_pSpriteManager->ModifySpriteRot(sVirus9, 0.0005f);

		// Move Matr around the game after he collides w/ the terminal
	/*	if(m_pSpriteManager->SpriteCollision(sPuzzleScreen, m_pDirectInput->currentMousePos))
			bGamePieceAttached = true;*/
//		if(bGamePieceAttached)
//		{	
			m_pSpriteManager->ModifySpritePos(sMatrball, (float)m_pDirectInput->currentMousePos.x, 675 );
			m_pSpriteManager->ModifySpritePos(iMaxSprite, (float)m_pDirectInput->currentMousePos.x, (float)m_pDirectInput->currentMousePos.y);
			//SetCursor(NULL);
			// Stop MATR from falling off the platform for now
			if(m_pDirectInput->currentMousePos.x < 240)
			{
				m_pSpriteManager->ModifySpritePos(sMatrball, 240, 675);//m_pSpriteManager->ModifySpritePos(sMatrball, 210, 770);
			}
			else if(m_pDirectInput->currentMousePos.x > 775)
			{
				m_pSpriteManager->ModifySpritePos(sMatrball, 775, 675);//m_pSpriteManager->ModifySpritePos(sMatrball, 800, 770);
			}

			// Check if the left mouse button was pressed & set collision with the Target & viruses for shooting
			if(m_pDirectInput->CheckMouseButtons(0)&& sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sVirus0, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus0, -80, -80);
					bK0 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus1, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus1, -80, -80);
					bK1 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus2, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus2, -80, -80);
					bK2 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus3, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus3, -80, -80);
					bK3 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus4, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus4, -80, -80);
					bK4 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus5, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus5, -80, -80);
					bK5 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus6, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus6, -80, -80);
					bK6 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus7, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus7, -80, -80);
					bK7 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus8, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus8, -80, -80);
					bK8 = true;
					sClickTimer = 0;
				}
				if(m_pSpriteManager->SpriteCollision(sVirus9, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sVirus9, -80, -80);
					bK9 = true;
					sClickTimer = 0;
				}
			}
			//Check to see if viruses are all dead
			else if(bK0 && bK1 && bK2 && bK3 && bK4 && bK5 && bK6 && bK7 && bK8 && bK9)
			{
				if(m_pSpriteManager->SpriteCollision(sPuzzleScreen, m_pDirectInput->currentMousePos))
				{
					m_pSpriteManager->ModifySpritePos(sScreen, 512, 384);
					m_pSpriteManager->ModifySpritePos(sStop, 120, 570);
				}
			}
			if(m_pSpriteManager->SpriteCollision(sStop, m_pDirectInput->currentMousePos))
			{
				bGameOver = true;
				bC4 = true;
			}
		//}
	}
	if(bGameOver)
	{
		if(bC4)
		{
			bSuccess = true;
			if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
			{
				if(m_pSpriteManager->SpriteCollision(sSuccess, m_pDirectInput->currentMousePos))
				{
					bSuccess = false;
					sClickTimer = 0;
					bGameWon = true;
					bGameOver = false;
					sGameState = 1;
					m_pModelManager->ModifyModelPos(5, -50, 0, 0);
				}
			}
		}
	}
	if(lTotalTime < 0)
	{
		bOutOfTime = true;
		if(m_pDirectInput->CheckMouseButtons(0) && sClickTimer > 1)
		{
			if(m_pSpriteManager->SpriteCollision(sOutOfTime, m_pDirectInput->currentMousePos))
			{
				bOutOfTime = false;
				bGameOver = false;
				sGameState = 1;
				sClickTimer = 0;
			}
		}
	}
}

short MiniGame::GetStateMiniGame(void)
{
	return sGameState;
}
bool MiniGame::CheckTerminal1Beat(void)
{
	return bGameWon;
}
void MiniGame::DestroyMiniGame(void)
{
	for(short i = iMaxSprite; i >= sSuccess; i--)
		m_pSpriteManager->DestroySprite(i);
}